package cn.good.yan.controller;

import cn.good.yan.entities.Bxx;
import cn.good.yan.resp.ResultData;
import cn.good.yan.serivce.BxxService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 演示：分布式事务  - bxx
 * 依次的启动： 2001 、 2002 、 2003
 * 发起者在 - BxxServiceImpl
 *
 * @author shengren.yan
 * @create 2022-04-06
 */
@RestController
public class BxxController {

    @Resource
    private BxxService bxxService;

    /**
     * 创建订单
     */
    @GetMapping("/bcc/create/{num}")
    public ResultData create(@PathVariable("num") Integer num) {
        Bxx bxx = new Bxx();
        bxx.setId(1l);
        bxx.setUserId(1l);
        bxx.setProductId(1l);
        bxx.setCount(num);
        bxx.setMoney(num * 10l);
        bxxService.create(bxx);
        return ResultData.success(bxx);
    }

}
